using System;
using System.Globalization;
using Thunder.Vector.Model.Shapes;

namespace Thunder.Vector.Model.Units
{
	public class Unit
	{
		private Entity parent;
		private float val;
		private UnitTypes type;
		
		public Entity Parent
		{
			get { return parent; }
			set { parent = value; }
		}
		public float Value
		{
			get { return val; }
			set { val = value; }
		}
		public UnitTypes Type
		{
			get { return type; }
			set { type = value; }
		}
		
		public Unit(Entity parent, float val, UnitTypes type)
		{
			this.parent = parent;
			this.val = val;
			this.type = type;
		}
		
		// TODO
		public static Unit operator +(Unit a, Unit b)
		{
			return new Unit(a.parent, a.val + b.val, a.Type);
		}
		// TODO
		public static Unit operator -(Unit a, Unit b)
		{
			return new Unit(a.parent, a.val - b.val, a.Type);
		}
		
		public static Unit Parse(Entity parent, string str)
		{
			float val;
			
			if (!float.TryParse(str, NumberStyles.Float, NumberFormatInfo.InvariantInfo, out val))
			{	
				throw new NotImplementedException();
			}
			
			return new Unit(parent, val, UnitTypes.Pixel);
		}
	}
}

